package com.ruoyi.inspection.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.inspection.domain.GovernCheckTaskItemScore;
import com.ruoyi.inspection.service.GovernCheckTaskItemScoreService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 政府下发专项任务检查项细则表(GovernCheckTaskItemScore)表控制层
 *
 * @author makejava
 * @since 2024-06-18 10:49:02
 */
@RestController
@Api("任务检查细则接口")
@RequestMapping("/check/governCheckTaskItemScore")
public class GovernCheckTaskItemScoreController extends BaseController {
    /**
     * 服务对象
     */
    @Resource
    private GovernCheckTaskItemScoreService governCheckTaskItemScoreService;

    /**
     * 分页查询
     *
     * @param governCheckTaskItemScore 筛选条件
     * @return 查询结果
     */
    @ApiOperation("任务细则列表")
    @GetMapping("/list")
    public TableDataInfo queryByPage(GovernCheckTaskItemScore governCheckTaskItemScore) {
        startPage();
        List<GovernCheckTaskItemScore> governCheckTaskItemScores = this.governCheckTaskItemScoreService.queryByPage(governCheckTaskItemScore);
        return getDataTable(governCheckTaskItemScores);
    }

    /**
     * 通过任务子项ID查询单条数据
     *
     * @param governCheckTaskItemId 下发任务子项ID
     * @return 单条数据
     */
    @ApiOperation("任务细则")
    @GetMapping("/get/{governCheckTaskItemId}")
    public AjaxResult queryById(@PathVariable("governCheckTaskItemId") String governCheckTaskItemId) {
        return AjaxResult.success(this.governCheckTaskItemScoreService.selectByGovernCheckTaskItemId(governCheckTaskItemId));
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public AjaxResult queryById(@PathVariable("id") Long id) {
        return AjaxResult.success(this.governCheckTaskItemScoreService.queryById(id));
    }

    /**
     * 新增数据
     *
     * @param governCheckTaskItemScore 实体
     * @return 新增结果
     */
    @PostMapping
    public AjaxResult add(GovernCheckTaskItemScore governCheckTaskItemScore) {
        return AjaxResult.success(this.governCheckTaskItemScoreService.insert(governCheckTaskItemScore));
    }

    /**
     * 编辑数据
     *
     * @param governCheckTaskItemScore 实体
     * @return 编辑结果
     */
    @PutMapping
    public AjaxResult edit(GovernCheckTaskItemScore governCheckTaskItemScore) {
        return AjaxResult.success(this.governCheckTaskItemScoreService.update(governCheckTaskItemScore));
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping
    public AjaxResult deleteById(Long id) {
        return AjaxResult.success(this.governCheckTaskItemScoreService.deleteById(id));
    }

}

